<?php

namespace app\common\model;

use think\Db;
use think\Model;

/**
 * 订单发票模型 
 */
class OrdersInvoiceModel extends Model {

    protected $dbName;

    public function __construct() {
        parent::__construct();
        $this->dbName = 'orders_invoice';
    }

    // 列表查询
    public function getAll($where, $join, $page, $pageSize, $field, $order) {
    
        $result = Db::name($this->dbName)->where($where)
                ->join($join)
                ->field($field)
                ->page($page, $pageSize)
                ->order($order)
                ->select();
        return $result;
    }

    // 数量查询
    public function getCount($where, $join) {
        $result = Db::name($this->dbName)
                ->where($where)
                ->join($join)
                ->count();
        return $result;
    }

    // 单个查询
    public function getOne($where, $join, $field) {
        $result = Db::name($this->dbName)
                ->where($where)
                ->join($join)
                ->field($field)
                ->find();
        return $result;
    }

    // 添加
    public function add($data)
    {
        return Db::name($this->dbName)->insertGetId($data);
    }
}
